/**
 * Store for Employees
 */
Ext.define("Cps.store.Employees",
{
    extend: "Ext.data.Store",
	
	model: 'Cps.model.Employee',
	
	config: {
		params: null
	},
	
    constructor: function (config)
    {
		if(config)
			this.initConfig(config);
		this.callParent([
		{
			storeId: 'Employees',			
			data: []
		}]);
		
    },
	initData: function(checkSetValue, control) {
		var Employee = this, f_data = [];
		Ext.Ajax.request({
			method: 'GET',
			url: Cps.Config.Api.getEmployee,
			success: function(data) {
				if (IsJson(data.responseText))
				{
					data = Ext.JSON.decode(data.responseText).data;
					data = data ? data.ttEmployee : null;
					data = data ? data.ttEmployeeRow : null;
					if (data != undefined)
					{
						if (data.length != undefined)
						{
							for(i = 0; i < data.length; i++) {
								if (data[i].EmployeeIsActiv)
									f_data.push(data[i]);
							}
						}
						else
							f_data.push(data);
					}
					Employee.loadData(f_data);
				}				
				if (checkSetValue)
					setValueForm(control,'Employee');
			},
			scope: this
		});
	}
});

		